package com.hcbd.tdwt.base.other;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.KeyEvent;

import com.hcbd.tdwt.base.BeidouBoxParams;
import com.hcbd.tdwt.base.GlobalParams;
import com.hcbd.tdwt.base.bd.BdToolFactory;
import com.hcbd.tdwt.util.ConvertData;

public class ShutdownReceiver extends BroadcastReceiver {

    private String TAG = "ShutdownReceiver";
    public static String filter = "com.xinyi.action.SHUTDOWN_FIVE_SECOND_LATER";
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.e(TAG, "收到广播："+intent.getAction());
        if (intent.getAction().equals(filter)) {
            // 关机
            Log.e(TAG,"监听到系统关机");
            if(BeidouBoxParams.isBoxConnectNormal){
                // 发混合模式消息
                String contentHex="A4"+ConvertData.stringToHex("设备关机").toUpperCase();
                BdToolFactory.getBdSendBase().sendMsg(GlobalParams.rdCentreNumber,2,3,contentHex);
            }else{
                Log.e(TAG, "未打开北斗模块");
            }
        }
    }
}
